package services;

import models.Config;
import models.Constants;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Gipxy group
 * Date: 4/2/12
 */
public class ConfigService {
    public static String getProductMenu() {
        Config productMenuConfig = Config.all(Config.class).filter("key", Constants.CONFIG_MENU_PRODUCT_KEY).get();

        if (productMenuConfig==null) {
            try {
                InputStream is = ConfigService.class.getResourceAsStream("productMenu.html");
                String text = IOUtils.toString(is);
                return text;
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            return productMenuConfig.value;
        }

        return "";
    }
}
